package com.huanxing.cloud.mall.api.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huanxing.cloud.mall.api.mapper.GoodsSkuMapper;
import com.huanxing.cloud.mall.api.service.IGoodsSkuService;
import com.huanxing.cloud.mall.common.entity.GoodsSku;
import com.huanxing.cloud.mall.common.entity.GoodsSpu;
import org.springframework.stereotype.Service;

/**
 * 商品sku
 *
 * @author lijx
 * @since 2022/2/26 16:37
 */
@Service
public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> implements IGoodsSkuService {

	@Override
	public boolean updateStock(String skuId, Integer buyQuantity) {
		return baseMapper.update(new GoodsSku(),
				Wrappers.<GoodsSku>lambdaUpdate()
					.eq(GoodsSku::getId, skuId)
					.setSql(" stock = stock + " + buyQuantity)) > 0;
	}

}
